

#define __STDC_CONSTANT_MACROS
#define __STDINT_LIMITS
#include <stdint.h>

#include <stdio.h>
#include <iostream>


#include "SkBitmap.h"
#include "SkPaint.h"
#include "SkCanvas.h"
#include "SkImageEncoder.h"
#include "SkTypeface.h"

using namespace std;


SkBitmap draw(int w, int h) {
    //声明
    SkBitmap bitmap;
    //设置Bitmap的配置信息
    bitmap.setInfo(SkImageInfo::Make(w, h, kBGRA_8888_SkColorType, kOpaque_SkAlphaType));
    //转换为像素填充
    bitmap.allocPixels();
    //创建画布
    SkCanvas canvas(bitmap);
    //创建画笔
    SkPaint paint;
    //设置画布颜色
    canvas.clear(SK_ColorWHITE);
    //设置画笔抗锯齿
    paint.setAntiAlias(true);
    //设置画笔颜色(此处为红色)
    paint.setARGB(255, 255, 0, 0);
    //绘制圆形
    canvas.drawCircle(80, 80, 40, paint);
    //绘制线段
    canvas.drawLine(0, 280, w, 280, paint);
    //设置字体大小
    paint.setTextSize(60);
    //绘制字体
    canvas.drawString("Hello Skia", 300, 150, paint);
    //返回SkBitmap对象
    return bitmap;
}



int main()
{
    printf("begin ...\n");

    SkBitmap bitmap = draw(600, 400);
    printf("%d*%d\n", bitmap.width(), bitmap.height());

    printf("end.\n");

    return 0;
}
